<template>
  <div class="dashboard-container">
    <el-card class="welcome-card">
      <div class="welcome-content">
        <h2>欢迎来到管理系统</h2>
        <p>请选择左侧菜单进行操作</p>
        <!-- 添加用户信息展示 -->
        <div class="user-info" v-if="userStore.isLogin">
          <p>当前用户: {{ userStore.getUserName }}</p>
          <p>用户角色: {{ userStore.getUserRole }}</p>
        </div>
      </div>
    </el-card>
    
    <div class="stats-container">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-item">
              <div class="stat-icon bg-blue">
                <el-icon><User /></el-icon>
              </div>
              <div class="stat-info">
                <div class="stat-value">128</div>
                <div class="stat-label">用户数</div>
              </div>
            </div>
          </el-card>
        </el-col>
        
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-item">
              <div class="stat-icon bg-green">
                <el-icon><Document /></el-icon>
              </div>
              <div class="stat-info">
                <div class="stat-value">56</div>
                <div class="stat-label">文章数</div>
              </div>
            </div>
          </el-card>
        </el-col>
        
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-item">
              <div class="stat-icon bg-orange">
                <el-icon><Tickets /></el-icon>
              </div>
              <div class="stat-info">
                <div class="stat-value">23</div>
                <div class="stat-label">订单数</div>
              </div>
            </div>
          </el-card>
        </el-col>
        
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-item">
              <div class="stat-icon bg-red">
                <el-icon><Comment /></el-icon>
              </div>
              <div class="stat-info">
                <div class="stat-value">89</div>
                <div class="stat-label">评论数</div>
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
    
    <!-- 添加主题信息展示 -->
    <el-card class="theme-info-card">
      <h3>当前主题信息</h3>
      <p>主题模式: {{ themeStore.theme }}</p>
      <p>系统主题偏好: {{ themeStore.systemTheme }}</p>
      <p>是否暗色主题: {{ themeStore.isDarkTheme ? '是' : '否' }}</p>
    </el-card>
  </div>
</template>

<script>
import { User, Document, Tickets, Comment } from '@element-plus/icons-vue'
import { useUserStore, useThemeStore } from '../stores/modules'

export default {
  name: 'Dashboard',
  components: {
    User,
    Document,
    Tickets,
    Comment
  },
  setup() {
    const userStore = useUserStore()
    const themeStore = useThemeStore()
    
    return {
      userStore,
      themeStore
    }
  }
}
</script>

<style scoped>
.dashboard-container {
  padding: 20px;
}

.welcome-card {
  margin-bottom: 20px;
}

.welcome-content {
  text-align: center;
  padding: 20px 0;
}

.welcome-content h2 {
  font-size: 24px;
  margin-bottom: 10px;
}

.welcome-content p {
  color: #666;
}

.user-info {
  margin-top: 15px;
  padding: 10px;
  background-color: #f5f7fa;
  border-radius: 4px;
}

.user-info p {
  margin: 5px 0;
}

.stats-container {
  margin-top: 20px;
}

.stat-card {
  border-radius: 8px;
}

.stat-item {
  display: flex;
  align-items: center;
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 15px;
  color: #fff;
  font-size: 20px;
}

.bg-blue {
  background-color: #409eff;
}

.bg-green {
  background-color: #67c23a;
}

.bg-orange {
  background-color: #e6a23c;
}

.bg-red {
  background-color: #f56c6c;
}

.stat-info {
  flex: 1;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 5px;
}

.stat-label {
  color: #666;
  font-size: 14px;
}

.theme-info-card {
  margin-top: 20px;
}

.theme-info-card h3 {
  margin-top: 0;
}

/* 暗色主题下的文字颜色优化 */
html.dark .welcome-content p,
html.dark .stat-label,
html.dark .theme-info-card {
  color: #cfd3dc !important;
}

html.dark .welcome-content h2 {
  color: #e5eaf3 !important;
}

html.dark .user-info {
  background-color: #1d1e1f;
}
</style>